package com.teen9g.infoplatformserver.config;

import com.teen9g.infoplatformserver.interceptor.JwtTokenAdminInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 配置类，注册相关组件Components
 */
@Configuration
@Slf4j
public class webconfig implements WebMvcConfigurer {

    @Autowired
    private JwtTokenAdminInterceptor jwtTokenAdminInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtTokenAdminInterceptor)
                .addPathPatterns("/**")  //默认拦截所有方法
                .excludePathPatterns("/api/**", "/user/**", "/static/**", "/common/**"); //放行登录方法和静态资源
        log.info("注册JWT拦截器");
    }
}
